package com.cp.mtq.bean;

import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class LoginInterceptor extends HandlerInterceptorAdapter {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws IOException {
        Object mtqToken = request.getSession().getAttribute("mtqToken");
        if(mtqToken!=null){
            return true;
        }
        response.sendRedirect("http://tuoguanjy.cn/mtq/static/login.html");
        return false;
    }
}
